package org.yray.sip.wav;


import org.apache.commons.io.FileUtils;
import org.yray.sip.utils.ByteUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;


public class WavUtils {


    public static boolean isWav8K(byte[] bs)
    {
       int samplesPerSec= ByteUtils.uBytes2Int(bs[27],bs[26],bs[25],bs[24]);
       return samplesPerSec==8000;
    }

    public static  byte[] pcm8k216k(byte[] inB)
    {
        byte[] outB=new byte[inB.length*2];
        for (int i = 1, iInx = 0; i < inB.length;)
        {
            outB[iInx++] = inB[i - 1];
            outB[iInx++] = inB[i];
            outB[iInx++] = inB[i - 1];
            outB[iInx++] = inB[i];
            i += 2;
        }
        return outB;
    }

    public static void main(String[] args) throws IOException {
        String wavfilePath="D:\\test\\wav\\24989763628768518\\3da99893f8cc0579428a100720cce67f.wav";
        byte[] bs=FileUtils.readFileToByteArray(new File(wavfilePath));
        System.out.println(isWav8K(bs));
    }
}

